home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Scope / Scope Disk #017 (199x)(Scope PD)(US)[WB].zip / Scope Disk #017 (199x)(Scope PD)(US)[WB].adf / QMouse1.0 / QMouse.asm < prev    next >
Assembly Source File  |  1988-06-29  |  23KB  |  934 lines

  1. ;                          QMouse 1.0  by Lyman Epp
  2. ;
  3. ;        Another "Mouse Accelerator???"  What for?  It seems that all the
  4. ;        other mouse accelerators have been written in "C".  This is okay,
  5. ;        but the programs are 10-20K.  This mouse accelerator is written
  6. ;        in assembler and contains most of the features of the others, but
  7. ;        the program size is less than 3K bytes!  Also, the source is
  8. ;        included so that you can add more features (please send me a copy
  9. ;        if you do.)  QMouse stands for "Quick Mouse."
  10. ;
  11. ;        This is being distributed as ShareWare.  If you think that QMouse
  12. ;        is useful, please send $10.  If you don't think that it is useful,
  13. ;        then why are you using it?  Your response will insure the release
  14. ;        of more quality programs for your Amiga!  Programs already in the
  15. ;        works include: a disk based print spooler, a window dump that
  16. ;        converts the window bitmap back to text, a file viewer, and more.
  17. ;
  18. ;                Lyman R. Epp
  19. ;                10072 Wirt Plaza #15
  20. ;                Omaha, Nebraska 68134
  21.  
  22.  
  23.         section text,CODE
  24.  
  25.         INCLUDE "exec/types.i"
  26.         INCLUDE "exec/libraries.i"
  27.         INCLUDE "exec/interrupts.i"
  28.         INCLUDE "exec/memory.i"
  29.         INCLUDE "libraries/dosextens.i"
  30.         INCLUDE "devices/input.i"
  31.         INCLUDE "devices/inputevent.i"
  32.         INCLUDE "graphics/clip.i"
  33.         INCLUDE "graphics/gfx.i"
  34.         INCLUDE "graphics/gfxbase.i"
  35.         INCLUDE "graphics/copper.i"
  36.         INCLUDE "hardware/custom.i"
  37.         INCLUDE "hardware/dmabits.i"
  38.         INCLUDE "intuition/intuition.i"
  39.         INCLUDE "intuition/intuitionbase.i"
  40.  
  41.  
  42. RAW_M               EQU     $37
  43. RAW_ESCAPE          EQU     $45
  44. RAW_F1              EQU     $50
  45.  
  46. CLOCKTOFRONT_SECS   EQU     10
  47. CLOCK_WIDTH         EQU     44
  48.  
  49. FLAGB_BLANK         EQU     0
  50. FLAGB_POINTEROFF    EQU     1
  51. FLAGB_NO_AMIGA_M    EQU     2
  52. FLAGB_CLOCK         EQU     3
  53.  
  54. POSTB_BLANK         EQU     0
  55. POSTB_UNBLANK       EQU     1
  56. POSTB_NEWCLI        EQU     2
  57. POSTB_TIMER         EQU     3
  58. POSTB_SHUFFLE       EQU     4
  59. POSTB_QUIT          EQU     5
  60.  
  61.  
  62.  
  63.         STRUCTURE work,0
  64.  
  65.         APTR    dosBase
  66.         APTR    gfxBase
  67.         APTR    layersBase
  68.         APTR    intuitionBase
  69.  
  70.         APTR    commandLine
  71.         APTR    qmouseTask
  72.         ULONG   qmouseSignal
  73.         UBYTE   qmousePost
  74.         UBYTE   qmouseFlag
  75.  
  76.         APTR    inputDev
  77.         APTR    clockWindow
  78.         APTR    blankScreen
  79.         APTR    blankSprite
  80.         APTR    saveSprite
  81.         ULONG   nullHandle
  82.         ULONG   timerSec
  83.         UWORD   blankTimer
  84.         UWORD   pointerTimer
  85.         UWORD   clockToFront
  86.         UWORD   clicksLeft
  87.         APTR    clickWindow
  88.         STRUCT  clickTime,8
  89.  
  90.         STRUCT  execCommand,100
  91.  
  92.         STRUCT  inputReqBlk,IOSTD_SIZE
  93.         STRUCT  handlerStuff,IS_SIZE
  94.  
  95.         LABEL   work_SIZEOF
  96.  
  97.  
  98.  
  99.         XREF    _AbsExecBase
  100.         XREF    CreatePort
  101.         XREF    DeletePort
  102.  
  103.  
  104. CALLSYS MACRO
  105.         xref    _LVO\1
  106.         CALLLIB _LVO\1
  107.         ENDM
  108.  
  109. LINKSYS MACRO
  110.         xref    _LVO\1
  111.         LINKLIB _LVO\1,\2
  112.         ENDM
  113.  
  114. ON_DISPLAY  MACRO
  115.         move.l  #$dff000,a0
  116.         move.w  #BITSET!DMAF_RASTER,dmacon(a0)
  117.         ENDM
  118.  
  119. OFF_DISPLAY  MACRO
  120.         move.l  #$dff000,a0
  121.         move.w  #BITCLR!DMAF_RASTER,dmacon(a0)
  122.         ENDM
  123.  
  124.  
  125.         section text,CODE
  126.  
  127. QMouse:
  128.         move.l  _AbsExecBase,a6
  129.         lea     workarea,a5
  130.         move.l  a0,commandLine(a5)      ; save command line addr for later
  131.  
  132.         lea     dosName(pc),a1          ; open "dos.library"
  133.         moveq   #0,d0
  134.         CALLSYS OpenLibrary
  135.         move.l  d0,dosBase(a5)
  136.         beq     abort
  137.  
  138.         lea     graphicsName(pc),a1     ; open "graphics.library"
  139.         moveq   #0,d0
  140.         CALLSYS OpenLibrary
  141.         move.l  d0,gfxBase(a5)
  142.         beq     abort
  143.  
  144.         lea     layersName(pc),a1     ; open "layers.library"
  145.         moveq   #0,d0
  146.         CALLSYS OpenLibrary
  147.         move.l  d0,layersBase(a5)
  148.         beq     abort
  149.  
  150.         lea     intuitionName(pc),a1    ; open "intuition.library"
  151.         moveq   #0,d0
  152.         CALLSYS OpenLibrary
  153.         move.l  d0,intuitionBase(a5)
  154.         beq     abort
  155.  
  156.         lea     qmousePortName(pc),a1
  157.         CALLSYS FindPort
  158.         tst.l   d0
  159.         bne     abort
  160.  
  161.         movem.l defaultCommand(pc),d0-d1
  162.         movem.l d0-d1,execCommand(a5)
  163.         bsr     ParseInput
  164.  
  165.         move.l  #12,d0
  166.         move.l  #MEMF_CHIP!MEMF_PUBLIC!MEMF_CLEAR,d1
  167.         CALLSYS AllocMem                ; allocate working storage
  168.         move.l  d0,blankSprite(a5)
  169.         beq     abort
  170.         move.l  d0,a0
  171.         move.w  #$FE00,(a0)
  172.         move.w  #$FF00,2(a0)
  173.  
  174.         move.w  screenSecs(pc),blankTimer(a5)
  175.         move.w  pointerSecs(pc),pointerTimer(a5)
  176.         move.w  #CLOCKTOFRONT_SECS,clockToFront(a5)
  177.  
  178.         lea     nullName(pc),a1
  179.         move.l  a1,d1
  180.         move.l  #MODE_NEWFILE,d2
  181.         LINKSYS Open,dosBase(a5)
  182.         move.l  d0,nullHandle(a5)
  183.         beq     abort
  184.  
  185.         sub.l   a1,a1
  186.         CALLSYS FindTask
  187.         move.l  d0,qmouseTask(a5)
  188.         move.l  d0,a1
  189.         move.b  pr_MsgPort+MP_SIGBIT(a1),d1
  190.         moveq   #0,d0
  191.         bset    d1,d0
  192.         move.l  d0,qmouseSignal(a5)
  193.  
  194.         btst    #FLAGB_CLOCK,qmouseFlag(a5)
  195.         beq     Main_NoClock
  196.         lea     clockNewWindow(pc),a0
  197.         LINKSYS OpenWindow,intuitionBase(a5)
  198.         move.l  d0,clockWindow(a5)
  199.         beq     abort
  200.         bsr     Clock
  201. Main_NoClock:
  202.  
  203.         lea     qmousePortName(pc),a0
  204.         moveq   #0,d0
  205.         bsr     CreatePort
  206.         tst.l   d0
  207.         beq     abort
  208.  
  209.         lea     inputReqBlk(a5),a1
  210.         move.b  #NT_MESSAGE,LN_TYPE(a1)
  211.         move.w  #IOSTD_SIZE,MN_LENGTH(a1)
  212.         move.l  d0,MN_REPLYPORT(a1)
  213.  
  214.         lea     inputName(pc),a0
  215.         moveq   #0,d0
  216.         moveq   #0,d1
  217.         CALLSYS OpenDevice              ; A1 still contains inputReqBlk
  218.         move.l  d0,inputDev(a5)
  219.         bne     abort
  220.  
  221.         lea     MyHandler(pc),a1
  222.         lea     handlerStuff(a5),a0
  223.         move.b  #51,LN_PRI(a0)
  224.         move.l  a1,IS_CODE(a0)
  225.  
  226.         lea     inputReqBlk(a5),a1
  227.         move.l  a0,IO_DATA(a1)
  228.         move.w  #IND_ADDHANDLER,IO_COMMAND(a1)
  229.         CALLSYS DoIO
  230.  
  231.         move.l  qmouseTask(a5),a1
  232.         moveq   #10,d0
  233.         CALLSYS SetTaskPri
  234.  
  235. Main_Wait:
  236.         move.l  qmouseSignal(a5),d0
  237.         CALLSYS Wait
  238.  
  239.         bclr    #POSTB_BLANK,qmousePost(a5)
  240.         beq     Main_Blank
  241.         bsr     BlankScreen
  242. Main_Blank:
  243.         bclr    #POSTB_UNBLANK,qmousePost(a5)
  244.         beq     Main_Unblank
  245.         bsr     UnblankScreen
  246. Main_Unblank:
  247.         bclr    #POSTB_TIMER,qmousePost(a5)
  248.         beq     Main_Timer
  249.         bsr     Clock
  250. Main_Timer:
  251.         bclr    #POSTB_NEWCLI,qmousePost(a5)
  252.         beq     Main_Newcli
  253.         bsr     NewCLI
  254. Main_Newcli:
  255.         bclr    #POSTB_SHUFFLE,qmousePost(a5)
  256.         beq     Main_Shuffle
  257.         bsr     ScreenShuffle
  258. Main_Shuffle:
  259.         bclr    #POSTB_QUIT,qmousePost(a5)
  260.         beq     Main_Wait
  261.  
  262.  
  263.         lea     inputReqBlk(a5),a1
  264.         move.w  #IND_REMHANDLER,IO_COMMAND(a1)
  265.         CALLSYS DoIO
  266.  
  267.         lea     inputReqBlk(a5),a1
  268.         CALLSYS CloseDevice
  269.  
  270.         lea     inputReqBlk(a5),a1
  271.         move.l  MN_REPLYPORT(a1),d0
  272.         bsr     DeletePort
  273.  
  274.         bsr     PointerOn
  275.  
  276.  
  277. abort:
  278.         move.l  clockWindow(a5),d0
  279.         beq     Abort_NoWindow
  280.         move.l  d0,a0
  281.         LINKSYS CloseWindow,intuitionBase(a5)
  282. Abort_NoWindow:
  283.         move.l  blankSprite(a5),d0
  284.         beq     Abort_NoBlankSprite
  285.         move.l  d0,a1
  286.         moveq   #12,d0
  287.         CALLSYS FreeMem
  288. Abort_NoBlankSprite:
  289.         move.l  intuitionBase(a5),d0
  290.         beq     Abort_NoIntuitionLib
  291.         move.l  d0,a1
  292.         CALLSYS CloseLibrary
  293. Abort_NoIntuitionLib:
  294.         move.l  layersBase(a5),d0
  295.         beq     Abort_NoLayersLib
  296.         move.l  d0,a1
  297.         CALLSYS CloseLibrary
  298. Abort_NoLayersLib:
  299.         move.l  gfxBase(a5),d0
  300.         beq     Abort_NoGraphicsLib
  301.         move.l  d0,a1
  302.         CALLSYS CloseLibrary
  303. Abort_NoGraphicsLib:
  304.  
  305.         moveq   #5,d1
  306.         LINKSYS Exit,dosBase(a5)
  307.  
  308.  
  309.  
  310. ParseInput:
  311.         move.l  commandLine(a5),a2
  312.         moveq   #0,d1                    ; reset quoted flag
  313. Parse_Loop:
  314.         move.b  (a2)+,d2
  315.         cmpi.b  #10,d2
  316.         beq     Parse_Done
  317.         cmpi.b  #'"',d2
  318.         beq     Parse_QuoteChar
  319.         cmpi.b  #'-',d2
  320.         beq     Parse_Option
  321.         cmpi.b  #' ',d2
  322.         beq     Parse_Loop
  323.         bra     ErrUsage
  324.  
  325. Parse_Done:
  326.         btst    #31,d1
  327.         bne     ErrUsage
  328.         rts
  329.  
  330. Parse_QuoteChar:
  331.         bset    #31,d1
  332.         bra     Parse_Loop
  333.  
  334. Parse_Option:
  335.         move.b  (a2)+,d2
  336.         ori.b   #$20,d2                  ; force to lowercase
  337.         cmpi.b  #'a',d2                  ; Accel factor
  338.         beq     Parse_Acc
  339.         cmpi.b  #'c',d2                  ; Clock enable
  340.         beq     Parse_Clock
  341.         cmpi.b  #'e',d2                  ; Execute command
  342.         beq     Parse_Exec
  343.         cmpi.b  #'k',d2                  ; number of clicks (to front)
  344.         beq     Parse_Klick
  345.         cmpi.b  #'m',d2                  ; Amiga-M disable
  346.         beq     Parse_Amiga_M
  347.         cmpi.b  #'p',d2                  ; Pointer Off seconds
  348.         beq     Parse_Pointer
  349.         cmpi.b  #'s',d2                  ; Screen Blank seconds
  350.         beq     Parse_Screen
  351.         cmpi.b  #'t',d2                  ; Accel thresh-hold
  352.         beq     Parse_Thresh
  353.         bra     ErrUsage
  354.  
  355. Parse_Next:
  356.         bclr    #31,d1
  357.         beq     Parse_Loop
  358.         cmpi.b  #'"',(a2)+
  359.         beq     Parse_Loop
  360.         bra     ErrUsage
  361.  
  362. Parse_Acc:
  363.         bsr     GetNumber
  364.         move.w  d0,mouseAccel
  365.         bra     Parse_Next
  366.  
  367. Parse_Clock:
  368.         bset    #FLAGB_CLOCK,qmouseFlag(a5)
  369.         bsr     GetNumber
  370.         tst.w   d0
  371.         beq     Parse_Next
  372.         move.l  intuitionBase(a5),a1
  373.         move.l  ib_FirstScreen(a1),a1
  374.         move.w  sc_Width(a1),d1
  375.         subi.w  #CLOCK_WIDTH,d1
  376.         cmp.w   d1,d0
  377.         bgt     Parse_Next
  378.         lea     clockNewWindow(pc),a1
  379.         move.w  d0,nw_LeftEdge(a1)
  380.         bra     Parse_Next
  381.  
  382. Parse_Exec:
  383.         lea     execCommand(a5),a1
  384. Parse_ExecLoop:
  385.         move.b  (a2)+,d2
  386.         cmpi.b  #10,d2
  387.         beq     Parse_ExecDone
  388.         btst    #31,d1
  389.         bne     Parse_ExecQuoted
  390.         cmpi.b  #' ',d2                  ; end of the field?
  391.         bne     Parse_ExecMove
  392.         bra     Parse_ExecDone
  393. Parse_ExecQuoted:
  394.         cmpi.b  #'"',d2                  ; end of the field?
  395.         beq     Parse_ExecDone
  396. Parse_ExecMove:
  397.         move.b  d2,(a1)+
  398.         bra     Parse_ExecLoop
  399. Parse_ExecDone:
  400.         move.b  -(a2),d2                 ; point at char that terminated
  401.         clr.b   (a1)                     ; terminate the execute string
  402.         bra     Parse_Next
  403.  
  404. Parse_Klick:
  405.         bsr     GetNumber
  406.         move.w  d0,numClicks
  407.         bra     Parse_Next
  408.  
  409. Parse_Amiga_M:
  410.         bset    #FLAGB_NO_AMIGA_M,qmouseFlag(a5)
  411.         bra     Parse_Next
  412.  
  413. Parse_Pointer:
  414.         bsr     GetNumber
  415.         move.w  d0,pointerSecs
  416.         bra     Parse_Next
  417.  
  418. Parse_Screen:
  419.         bsr     GetNumber
  420.         move.w  d0,screenSecs
  421.         bra     Parse_Next
  422.  
  423. Parse_Thresh:
  424.         bsr     GetNumber
  425.         move.w  d0,accelThresh
  426.         bra     Parse_Next
  427.  
  428.  
  429. GetNumber:
  430.         moveq   #0,d0
  431.         moveq   #0,d2
  432. GetNumberLoop:
  433.         move.b  (a2)+,d2
  434.         cmpi.b  #'0',d2
  435.         blt     GetNumber_Exit
  436.         cmpi.b  #'9',d2
  437.         bgt     GetNumber_Exit
  438.         subi.b  #'0',d2
  439.         mulu    #10,d0
  440.         add.w   d2,d0
  441.         bra     GetNumberLoop
  442. GetNumber_Exit:
  443.         move.b  -(a2),d2                 ; point at char that terminated
  444.         rts
  445.  
  446.  
  447. ErrUsage:
  448.         lea     ERR_USAGE(pc),a2
  449.         move.l  a2,d2
  450.         moveq   #ERR_USAGE_SIZE,d3
  451.         bra     ErrDisplay
  452.  
  453. ErrFatal:
  454.         lea     ERR_FATAL(pc),a2
  455.         move.l  a2,d2
  456.         moveq   #ERR_FATAL_SIZE,d3
  457.         bra     ErrDisplay
  458.  
  459. ErrDisplay:
  460.         LINKSYS Output,dosBase(a5)
  461.         move.l  d0,d1
  462.         LINKSYS Write,dosBase(a5)
  463.         bra     abort
  464.  
  465.  
  466.  
  467. PointerOff:
  468.         move.l  gfxBase(a5),a1
  469.         move.l  gb_copinit(a1),a1
  470.         bset    #FLAGB_POINTEROFF,qmouseFlag(a5)
  471.         bne     PointerOffSkip
  472.         move.w  copinit_sprstrtup+2(a1),saveSprite+0(a5)
  473.         move.w  copinit_sprstrtup+6(a1),saveSprite+2(a5)
  474. PointerOffSkip:
  475.         move.w  blankSprite+0(a5),copinit_sprstrtup+2(a1)
  476.         move.w  blankSprite+2(a5),copinit_sprstrtup+6(a1)
  477.  
  478. PointerOff_End:
  479.         rts
  480.  
  481.  
  482.  
  483. PointerOn:
  484.         bclr    #FLAGB_POINTEROFF,qmouseFlag(a5)
  485.         beq     PointerOn_End
  486.  
  487.         move.l  gfxBase(a5),a1
  488.         move.l  gb_copinit(a1),a1
  489.         move.w  saveSprite+0(a5),copinit_sprstrtup+2(a1)
  490.         move.w  saveSprite+2(a5),copinit_sprstrtup+6(a1)
  491.  
  492. PointerOn_End:
  493.         rts
  494.  
  495.  
  496.  
  497. BlankScreen:
  498.         lea     blankNewScreen(pc),a0
  499.         LINKSYS OpenScreen,intuitionBase(a5)
  500.         move.l  d0,blankScreen(a5)
  501.         beq     Blank_End
  502.  
  503.         move.l  d0,a0
  504.         lea     sc_ViewPort(a0),a0
  505.         moveq   #0,d0
  506.         moveq   #0,d1
  507.         moveq   #0,d2
  508.         moveq   #0,d3
  509.         LINKSYS SetRGB4,gfxBase(a5)
  510.  
  511.         OFF_DISPLAY
  512.  
  513.         bset    #FLAGB_BLANK,qmouseFlag(a5)
  514.  
  515. Blank_End:
  516.         rts
  517.  
  518.  
  519.  
  520. UnblankScreen:
  521.         bclr    #FLAGB_BLANK,qmouseFlag(a5)
  522.         beq     Unblank_End
  523.  
  524.         move.l  blankScreen(a5),a0
  525.         LINKSYS CloseScreen,intuitionBase(a5)
  526.  
  527.         ON_DISPLAY
  528.  
  529. Unblank_End:
  530.         rts
  531.  
  532.  
  533.  
  534. NewCLI:
  535.         LINKSYS WBenchToFront,intuitionBase(a5)
  536.  
  537.         lea     execCommand(a5),a1
  538.         move.l  a1,d1
  539.         move.l  nullHandle(a5),d2
  540.         move.l  d2,d3
  541.         LINKSYS Execute,dosBase(a5)
  542.  
  543. NewCLI_End:
  544.         rts
  545.  
  546.  
  547.  
  548. ScreenShuffle:
  549.         CALLSYS Forbid
  550.  
  551.         move.l  intuitionBase(a5),a0
  552.         move.l  ib_FirstScreen(a0),a0
  553.         LINKSYS ScreenToBack,intuitionBase(a5)
  554.  
  555.         CALLSYS Permit
  556.  
  557. Shuffle_End:
  558.         rts
  559.  
  560.  
  561.  
  562. Clock:
  563.         btst    #FLAGB_CLOCK,qmouseFlag(a5)
  564.         beq     Clock_End
  565.  
  566.         move.l  dosBase(a5),a0
  567.         move.l  dl_Root(a0),a0
  568.         move.l  rn_Time+ds_Minute(a0),d0
  569.  
  570.         divu    #60,d0
  571.         move.l  d0,d1                   ; save for calculating minutes
  572.         moveq   #16,d2                  ; used for shifting later...
  573.  
  574.         cmpi.w  #12,d0
  575.         ble     Clock_NotPM
  576.         subi.w  #12,d0
  577. Clock_NotPM:
  578.         tst.w   d0
  579.         bne     Clock_NotMidnite
  580.         moveq   #12,d0
  581. Clock_NotMidnite:
  582.         ext.l   d0
  583.         divu    #10,d0
  584.         ori.b   #'0',d0
  585.         cmpi.b  #'0',d0
  586.         bne     Clock_FirstCharOk
  587.         move.b  #' ',d0
  588. Clock_FirstCharOk:
  589.         lea     clockBuffer(pc),a0
  590.         move.b  d0,(a0)
  591.         lsr.l   d2,d0
  592.         ori.b   #'0',d0
  593.         move.b  d0,1(a0)
  594.  
  595.         lsr.l   d2,d1
  596.         ext.l   d1
  597.         divu    #10,d1
  598.         ori.b   #'0',d1
  599.         move.b  d1,3(a0)
  600.         lsr.l   d2,d1
  601.         ori.b   #'0',d1
  602.         move.b  d1,4(a0)
  603.  
  604.         moveq   #':',d1
  605.         cmp.b   2(a0),d1
  606.         bne     Clock_FlipFlop
  607.         moveq   #' ',d1
  608. Clock_FlipFlop:
  609.         move.b  d1,2(a0)
  610.  
  611.         move.l  clockWindow(a5),a0
  612.         move.l  wd_RPort(a0),a0
  613.         lea     clockText(pc),a1
  614.         moveq   #0,d0
  615.         moveq   #0,d1
  616.         LINKSYS PrintIText,intuitionBase(a5)
  617.  
  618.         sub.w   #1,clockToFront(a5)
  619.         bne     Clock_End
  620.         move.w  #CLOCKTOFRONT_SECS,clockToFront(a5)
  621.         move.l  clockWindow(a5),a0
  622.         LINKSYS WindowToFront,intuitionBase(a5)
  623.  
  624. Clock_End:
  625.         rts
  626.  
  627.  
  628. AccelMouse:
  629.         move.w  accelThresh(pc),d1
  630.         cmp.w   d1,d0
  631.         bgt     Accel_Yes
  632.         neg.w   d1
  633.         cmp.w   d1,d0
  634.         bge     Accel_No
  635. Accel_Yes:
  636.         sub.w   d1,d0
  637.         mulu    mouseAccel(pc),d0
  638.         add.w   d1,d0
  639. Accel_No:
  640.         rts
  641.  
  642.  
  643. CheckMouseClicks:
  644.         move.l  a0,-(sp)
  645.  
  646.         bsr     WhichMouseLayer           ; check if pointer is over a layer
  647.         tst.l   d0
  648.         beq     Click_None
  649.         move.l  d0,a1
  650.         move.l  lr_Window(a1),d4          ; check if pointer is over a window
  651.         beq     Click_None
  652.         move.l  lr_ClipRect(a1),d0        ; is this window already up front?
  653.         beq     Click_None                ; yes, don't waste more time!
  654.         move.l  d0,a1
  655.         tst.l   cr_Next(a1)               ; is this window already up front?
  656.         beq     Click_None                ; yes, don't waste more time!
  657.  
  658.         movem.l ie_TimeStamp(a0),d2-d3
  659.         cmp.l   clickWindow(a5),d4        ; same window as last click?
  660.         bne     Click_DiffWindow          ; no, reset clicks left
  661.         movem.l clickTime(a5),d0-d1       ; let intuition check if they
  662.         LINKSYS DoubleClick,intuitionBase(a5)  ; double clicked soon enough
  663.         tst.l   d0
  664.         bne     Click_CheckCount
  665. Click_DiffWindow:
  666.         move.w  numClicks(pc),clicksLeft(a5)
  667. Click_CheckCount:
  668.         movem.l d2-d3,clickTime(a5)
  669.         move.l  d4,clickWindow(a5)
  670.         subi.w  #1,clicksLeft(a5)
  671.         bne     Click_End
  672.         move.l  d4,a0
  673.         LINKSYS WindowToFront,intuitionBase(a5)
  674. Click_None:
  675.         move.w  numClicks(pc),clicksLeft(a5)
  676.  
  677. Click_End:
  678.         move.l  (sp)+,a0
  679.         rts
  680.  
  681.  
  682. WhichMouseLayer:
  683.         movem.l d1-d2/a0-a3,-(sp)
  684.  
  685.         CALLSYS Forbid
  686.  
  687.         move.l  intuitionBase(a5),a3
  688.         move.l  ib_FirstScreen(a3),d0
  689.         beq     Layer_Exit
  690. Layer_Loop:
  691.         move.l  d0,a2
  692.         move.w  ib_MouseY(a3),d2
  693.         move.w  sc_ViewPort+vp_Modes(a2),d0
  694.         andi.w  #V_LACE,d0
  695.         bne     Layer_Interlace
  696.         lsr.w   #1,d2
  697. Layer_Interlace:
  698.         lea     sc_LayerInfo(a2),a0
  699.         moveq   #0,d0
  700.         move.w  ib_MouseX(a3),d0
  701.         moveq   #0,d1
  702.         move.w  d2,d1
  703.         sub.w   sc_ViewPort+vp_DyOffset(a2),d1
  704.         LINKSYS WhichLayer,layersBase(a5)
  705.         tst.l   d0
  706.         bne     Layer_Exit
  707.         cmp.w   sc_ViewPort+vp_DyOffset(a2),d2
  708.         ble     Layer_Exit
  709.         move.l  sc_NextScreen(a2),d0
  710.         bne     Layer_Loop
  711.  
  712. Layer_Exit:
  713.         CALLSYS Permit
  714.  
  715.         movem.l (sp)+,d1-d2/a0-a3
  716.         rts
  717.  
  718.  
  719.  
  720. MyHandler:
  721.         movem.l a0/a5,-(sp)
  722.         lea     workarea,a5
  723.  
  724. Handler_Loop:
  725.         cmpi.b  #IECLASS_TIMER,ie_Class(a0)
  726.         bne     Handler_NotTimer
  727.         bsr     TimerEvent
  728.         bra     Handler_NextEvent
  729.  
  730. Handler_NotTimer:
  731.         bsr     NotTimerEvent
  732.         cmpi.b  #IECLASS_RAWMOUSE,ie_Class(a0)
  733.         bne     Handler_NotMouse
  734.         bsr     MouseEvent
  735.         bra     Handler_NextEvent
  736.  
  737. Handler_NotMouse:
  738.         cmpi.b  #IECLASS_RAWKEY,ie_Class(a0)
  739.         bne     Handler_NextEvent
  740.         bsr     RawKeyEvent
  741.  
  742. Handler_NextEvent:
  743.         move.l  ie_NextEvent(a0),d0
  744.         move.l  d0,a0
  745.         bne     Handler_Loop
  746.  
  747.         tst.b   qmousePost(a5)
  748.         beq     Handler_End
  749.  
  750.         move.l  qmouseTask(a5),a1
  751.         move.l  qmouseSignal(a5),d0
  752.         LINKSYS Signal,_AbsExecBase
  753.  
  754. Handler_End:
  755.         movem.l (sp)+,d0/a5
  756.         rts
  757.  
  758.  
  759.  
  760. TimerEvent:
  761.         move.l  ie_TimeStamp(a0),d0
  762.         cmp.l   timerSec(a5),d0
  763.         beq     Timer_End
  764.  
  765.         move.l  d0,timerSec(a5)
  766.         bset    #POSTB_TIMER,qmousePost(a5)
  767.  
  768.         move.w  pointerSecs(pc),d0          ; pointer blank enabled?
  769.         beq     Timer_NotPointer
  770.         btst    #FLAGB_POINTEROFF,qmouseFlag(a5)  ; Intuition will restore the
  771.         bne     Timer_PointerOff                  ; pointer--make sure it is off!
  772.         subq.w  #1,pointerTimer(a5)
  773.         bne     Timer_NotPointer
  774. Timer_PointerOff:
  775.         bsr     PointerOff
  776. Timer_NotPointer:
  777.  
  778.         move.w  screenSecs(pc),d0            ; Screen blank enabled?
  779.         beq     Timer_NotBlank
  780.         btst    #FLAGB_BLANK,qmouseFlag(a5)
  781.         bne     Timer_NotBlank
  782.         subq.w  #1,blankTimer(a5)
  783.         bne     Timer_NotBlank
  784.  
  785.         bset    #POSTB_BLANK,qmousePost(a5)
  786. Timer_NotBlank:
  787.  
  788. Timer_End:
  789.         rts
  790.  
  791.  
  792.  
  793. NotTimerEvent:
  794.         move.w  screenSecs(pc),blankTimer(a5)
  795.  
  796.         btst    #FLAGB_BLANK,qmouseFlag(a5)
  797.         beq     NotTimer_End            ; screen not blank -- return
  798.         bset    #POSTB_UNBLANK,qmousePost(a5)
  799.  
  800. NotTimer_End:
  801.         rts
  802.  
  803.  
  804.  
  805. MouseEvent:
  806.         movem.l d1-d3/a0,-(sp)
  807.  
  808.         move.w  pointerSecs(pc),pointerTimer(a5)
  809.  
  810.         btst    #FLAGB_POINTEROFF,qmouseFlag(a5)
  811.         beq     Mouse_NotPointer         ; pointer already on -- skip
  812.         bsr     PointerOn
  813. Mouse_NotPointer:
  814.  
  815.         cmpi.w  #1,mouseAccel
  816.         ble     Mouse_NoAccel
  817.         move.w  ie_Qualifier(a0),d0
  818.         btst    #IEQUALIFIERB_RELATIVEMOUSE,d0
  819.         beq     Mouse_NoAccel
  820.         move.w  ie_X(a0),d0
  821.         bsr     AccelMouse
  822.         move.w  d0,ie_X(a0)
  823.         move.w  ie_Y(a0),d0
  824.         bsr     AccelMouse
  825.         move.w  d0,ie_Y(a0)
  826. Mouse_NoAccel:
  827.  
  828.         move.w  numClicks(pc),d0            ; click to front enabled?
  829.         beq     Mouse_NoClick
  830.         cmpi.w  #IECODE_LBUTTON,ie_Code(a0)
  831.         bne     Mouse_NoClick
  832.         bsr     CheckMouseClicks
  833. Mouse_NoClick:
  834.  
  835. Mouse_End:
  836.         movem.l (sp)+,d1-d3/a0
  837.         rts
  838.  
  839.  
  840.  
  841. RawKeyEvent:
  842.         move.w  ie_Qualifier(a0),d0
  843.         btst    #IEQUALIFIERB_LCOMMAND,d0
  844.         beq     RawKey_End
  845.  
  846.         cmpi.w  #RAW_M,ie_Code(a0)
  847.         bne     RawKey_NotShuffle
  848.         move.b  #IECLASS_NULL,ie_Class(a0)
  849.         bset    #POSTB_SHUFFLE,qmousePost(a5)
  850. RawKey_NotShuffle:
  851.  
  852.         cmpi.w  #RAW_ESCAPE,ie_Code(a0)
  853.         bne     RawKey_NotNewcli
  854.         move.b  #IECLASS_NULL,ie_Class(a0)
  855.         bset    #POSTB_NEWCLI,qmousePost(a5)
  856. RawKey_NotNewcli:
  857.  
  858.         btst    #IEQUALIFIERB_CONTROL,d0
  859.         beq     RawKey_NotQuit
  860.         cmpi.w  #RAW_F1,ie_Code(a0)
  861.         bne     RawKey_NotQuit
  862.         move.b  #IECLASS_NULL,ie_Class(a0)
  863.         bset    #POSTB_QUIT,qmousePost(a5)
  864. RawKey_NotQuit:
  865.  
  866. RawKey_End:
  867.         rts
  868.  
  869.  
  870.  
  871.  
  872.  
  873. dosName          dc.b    'dos.library',0
  874. graphicsName     dc.b    'graphics.library',0
  875. layersName       dc.b    'layers.library',0
  876. intuitionName    dc.b    'intuition.library',0
  877. inputName        dc.b    'input.device',0
  878.  
  879. qmousePortName   dc.b    'QMouse 1.0 Port',0
  880. nullName         dc.b    'NIL:',0
  881.  
  882. mouseAccel       dc.w    3             ; defaults for these options!
  883. accelThresh      dc.w    3
  884. pointerSecs      dc.w    10
  885. screenSecs       dc.w    600
  886. numClicks        dc.w    2
  887. defaultCommand   dc.b    'NewCLI',0
  888.  
  889.  
  890. ERR_USAGE        dc.b    $9b,'0;33mQMouse 1.0',$9b,'0m  by Lyman Epp',10
  891.                  dc.b    'Usage: QMouse -A# -C# -Ecommand -K# -M -P# -S# -T#',10
  892. ERR_USAGE_SIZE   equ     *-ERR_USAGE
  893.  
  894. ERR_FATAL        dc.b    'QMouse: Fatal error',10
  895. ERR_FATAL_SIZE   equ     *-ERR_FATAL
  896.  
  897.  
  898. blankNewScreen   dc.w    0,0,320,30,1
  899.                  dc.b    0,0
  900.                  dc.w    0
  901.                  dc.w    CUSTOMSCREEN
  902.                  dc.l    0,0,0,0
  903.  
  904. clockNewWindow   ds.w    0
  905.                  dc.w    280,0
  906.                  dc.w    CLOCK_WIDTH,10
  907.                  dc.b    -1,2
  908.                  dc.l    0
  909.                  dc.l    SMART_REFRESH!NOCAREREFRESH
  910.                  dc.l    0,0,0,0,0
  911.                  dc.w    0,0
  912.                  dc.w    0,0
  913.                  dc.w    WBENCHSCREEN
  914.  
  915. clockBuffer      dc.b    '00:00',0
  916.  
  917. clockText        ds.w    0
  918.                  dc.b    3,2
  919.                  dc.b    RP_JAM2,0
  920.                  dc.w    2,1
  921.                  dc.l    0
  922.                  dc.l    clockBuffer
  923.                  dc.l    0
  924.  
  925.  
  926.  
  927.  
  928.         section data,BSS
  929.  
  930. workarea         ds.b    work_SIZEOF
  931.  
  932.         end
  933.  
  934.